package cn.bdqn.demo.dao;

import cn.bdqn.demo.bean.Order;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class OrderDao {
    @Resource
    JdbcTemplate jdbcTemplate;
    public int save(Order order) {
        return jdbcTemplate.update("insert into orders(cost,orderDate,productId,userId) values (?,?,?,?)",
                order.getCost(),
                order.getOrderDate(),
                order.getProductId(),
                order.getUserId());
    }
    public int count() {
        return jdbcTemplate.queryForObject("select count(id) from orders",Integer.class);
    }
}
